FROM maven:3.9.5-eclipse-temurin-8 AS builder
RUN if [ -d /app/src ]; then \
      cd /app/src && git pull; \
    else \
      git clone https://gitee.com/Wan_xiaowen/art-college.git /app/src; \
    fi

WORKDIR /app/src/java/biz
RUN mvn clean package -DskipTests -Dmaven.repo.local=/root/.m2/repository

FROM openjdk:8-jre-alpine

COPY --from=builder /app/src/java/biz/target/*.jar /app/app.jar

EXPOSE 8080
CMD ["java", "-jar", "/app/app.jar"]